<script setup>
import Navbar from "@/components/Navbar.vue";
import { useRoute, useRouter } from "vue-router";
import { onMounted, watch } from "vue";

const route = useRoute();
const router = useRouter();
const notRenderLayoutList = ["/login", "/welcome"];

// 监听路由变化，确保根路径跳转到welcome页面
watch(
  () => route.path,
  (newPath) => {
    if (newPath === "/") {
      router.push("/welcome");
    }
  },
  { immediate: true }
);

onMounted(() => {
  console.log("onMounted");
});
</script>

<template>
  <div>
    <Navbar v-if="notRenderLayoutList.indexOf(route.path) === -1" />
    <div class="main">
      <router-view></router-view>
    </div>
  </div>
</template>

<style scoped>
.main {
  width: 100%;
  height: 90vh;
  position: absolute;
  bottom: 0;
  overflow-y: auto;
}
</style>
